package com.tim.proxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class PerformaceHandler implements InvocationHandler {

	private Object target;

	public PerformaceHandler(Object target) {
		this.target = target;
	}

	public Object invoke(Object proxy, Method method, Object[] args)
			throws Throwable {
		PerformanceMonitoring.begin(target.getClass().getName() + "."
				+ method.getName());
		Object obj = method.invoke(target, args);// 通过反射调用方法
		PerformanceMonitoring.end();
		return obj;
	}
}
